#include "ImmutableObject.h"

ImmutableObject::ImmutableObject( RawObjectData *objData )
	: SceneObject( objData )
{
	if( !ListIDContainer::getInstance().getID(objData,_listID) )
	{
		//cout <<"ID: "<<_listID<<endl;
		int maxMeshes = objData->getMeshes()->size();
		for( int i = 0;i < maxMeshes;i++)
		{
			glNewList(_listID+i, GL_COMPILE);
				SceneObject::DrawObject(i);
			glEndList();
		}
	}
}

ImmutableObject::~ImmutableObject( )
{
	cout <<"_~ImmutableObject()_"<<endl;
	ListIDContainer::getInstance().delID(SceneObject::getRawData());
}

void ImmutableObject::DrawObject()
{
	//cout<<"___LIST_CALLED____OBJECT"<<endl;
	//long time =SDL_GetTicks();
	int maxMeshes = getRawData ()->getMeshes()->size();
	for( int i = 0;i < maxMeshes;i++)
	{
		//cout<<"___LIST_CALLED____MESH"<<endl;
		glCallList(_listID+i);
	}
	//cout <<"time_ms: "<<SDL_GetTicks() - time<<endl;
};


